<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%  
	String path = request.getContextPath();  
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";  
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>顾客列表</title>
<link rel="stylesheet" href="${pageContext.request.contextPath }/js/common/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="${pageContext.request.contextPath }/js/common/bootstrap/css/bootstrap-theme.min.css">
<script src="${pageContext.request.contextPath }/js/jquery-3.1.1.min.js"></script>
<script src="${pageContext.request.contextPath }/js/common/bootstrap/js/bootstrap.min.js"></script>		
<script src="${pageContext.request.contextPath }/js/common/bootstrapvaildator/js/bootstrapValidator.min.js"></script>
<script src="${pageContext.request.contextPath }/js/common/bootstrapvaildator/js/language/zh_CN.js"></script>
</head>
<!-- <body style="margin: 30px;"> -->
<body>
	<!-- <div class="container"> -->
		<center>
			<!-- 条件查询表单 -->
				<form class="form-inline" action="${pageContext.request.contextPath }/zjj/selectBis_custom_user" method="post" name="myform" id="myform">
					<table>
						<tr align="center">
							<td align="right">
								<div class="form-group">
									<label for="mobile">手机号：</label>
								</div>
							</td>
							<td align="left">
								<div class="form-group">
									<input type="text" class="form-control" id="mobile" name="mobile" value="${mobile }">
								</div>
							</td>
							<td align="right">
								<div class="form-group">
									<label for="username">姓名：</label>
								</div>
							</td>
							<td align="left">
								<div class="form-group">
									<input type="text" class="form-control" id="username" name="username" value="${username }">
								</div>
							</td>
							<td align="right">
								<div class="form-group">
									<label for="shop_id">店铺名称：</label>
								</div>
							</td>
							<td align="left">
								<div class="form-group">
									<div class="form-group">
									<select class="form-control" name="shop_id" id="shop_id">
									  	<option value="" selected="selected">请选择~！</option>
									  	<c:forEach items="${list2 }" var="list2">
											<option value="${list2.shop_id }">${list2.shop_name }</option>
										</c:forEach>
									</select>
								</div>
								</div>
							</td>
							<td align="right">
								<div class="form-group">
									<label for="enroll_mode">注册方式：</label>
								</div>
							</td>
							<td align="left">
								<div class="form-group">
									<select class="form-control" name="enroll_mode" id="enroll_mode">
									  <option value="">请选择~！</option>
									  <option value="1">微信</option>
									  <option value="2">商家</option>
									  <option value="3">后台</option>
									</select>
								</div>
							</td>
							<!-- 表单按钮组 -->
							<td rowspan="2">
								<button class="btn btn-primary btn-sm" type="submit" name="zjjinquiry" id="zjjinquiry">
									<span class="glyphicon glyphicon-search" aria-hidden="true"></span>&nbsp;&nbsp;查询
								</button>
								&nbsp;&nbsp;
								<button class="btn btn-primary btn-sm" type="button" name="zjjresetting" id="zjjresetting">
									<span class="glyphicon glyphicon-refresh" aria-hidden="true"></span>&nbsp;&nbsp;重置
								</button>
							</td>
						</tr>
						<tr align="center">
							<td align="right">
								<div class="form-group">
									<label for="custom_user_id">会员号：</label>
								</div>
							</td>
							<td align="left">
								<div class="form-group">
									<input type="text" class="form-control" id="custom_user_id" name="custom_user_id" value="${custom_user_id }">
								</div>
							</td>
							<td align="right">
								<div class="form-group">
									<label for="nikename">昵称：</label>
								</div>
							</td>
							<td align="left">
								<div class="form-group">
									<input type="text" class="form-control" id="nikename" name="nikename" value="${nikename }">
								</div>
							</td>
							<td align="right">
								<div class="form-group">
									<label for="wechat_status">微信状态：</label>
								</div>
							</td>
							<td align="left">
								<div class="form-group">
									<select class="form-control" name="wechat_status" id="wechat_status">
									  <option value="">请选择~！</option>
									  <option value="1">未订阅</option>
									  <option value="2">已订阅</option>
									  <option value="3">已退订</option>
									</select>
								</div>
							</td>
							<td align="right">
								<div class="form-group">
									<label for="recent_time">最近到店时间：</label>
								</div>
							</td>
							<td align="left">
								<div class="form-group">
									<input type="date" class="form-control" id="recent_time" name="recent_time" value="<f:formatDate value='${recent_time }' pattern='yyyy-MM-dd'/>">
								</div>
							</td>
						</tr>
						<tr>
							<td colspan="9">
								<!-- 功能组 -->
								<button class="btn btn-primary btn-sm" type="button" data-toggle="modal" data-target="#myModal1" data-backdrop="static">
									<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>&nbsp;&nbsp;新增
								</button>
							</td>
						</tr>
					</table>
				</form>
				
				<!-- 新增模态框 -->
				<div class="modal fade bs-example-modal-lg" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
				  <div class="modal-dialog modal-lg" role="document">
				    <div class="modal-content">
				      <div class="modal-header">
				        <button type="button" class="close" data-dismiss="modal" onclick="test1()" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				        <h4 class="modal-title" align="left">新增顾客信息</h4>
				      </div>
				      <div class="modal-body">
				      	<form action="" name="myform1" id="myform1" method="post" enctype="multipart/form-data">
				      	<%-- <form action="" name="myform1" id="myform1" method="post"> --%>
				        	<table class="table table-bordered">
				        		<tr>
				        			<td align="right">
				        				<div class="form-group">
											<label for="mobile">手机:</label>
										</div>
				        			</td>
				        			<td>
				        				 <div class="form-group">
										    <input type="text" class="form-control" name="mobile" id="mobile" placeholder="">
										 </div>
				        			</td>
				        			<td align="right">
				        				<div class="form-group">
											<label for="photo">头像：</label>
										</div>
				        			</td>
				        			<td>
				        				<div class="form-group">
				        					<input type="file" class="form-control" onchange="PreviewImage(this)" name="pic" id="pic" placeholder="">
				        					<div id="imgPreview"></div>
										</div>
				        			</td>
				        		</tr>
				        		<tr>
				        			<td align="right">
				        				<div class="form-group">
											<label for="username">姓名：</label>
										</div>
				        			</td>
				        			<td>
				        				<div class="form-group">
										    <input type="text" class="form-control" name="username" id="username" placeholder="">
										</div>
				        			</td>
				        			<td align="right">
				        				<div class="form-group">
											<label for="sex">性别：</label>
										</div>
				        			</td>
				        			<td>
				        				<div class="form-group">
										    <select class="form-control" name="sex" id="sex">
												<option value="1">男</option>
												<option value="2">女</option>											
												<option value="3">保密</option>
											</select>
										</div>
				        			</td>
				        		</tr>
				        		<tr>
				        			<td align="right">
				        				<div class="form-group">
											<label for="nikename">昵称：</label>
										</div>
				        			</td>
				        			<td>
				        				<div class="form-group">
										    <input type="text" class="form-control" name="nikename" id="nikename" placeholder="">
										</div>
				        			</td>
				        			<td align="right">
				        				<div class="form-group">
											<label for="born_date">出生日期：</label>
										</div>
				        			</td>
				        			<td>
				        				<div class="form-group">
										    <input type="date" class="form-control" name="born_date" id="born_date" placeholder="">
										</div>
				        			</td>
				        		</tr>
				        		<tr>
				        			<td align="right">
				        				<div class="form-group">
											<label for="phone">电话：</label>
										</div>
				        			</td>
				        			<td>
				        				<div class="form-group">
				        					<input type="text" class="form-control" name="phone" id="phone" placeholder="">
										</div>
				        			</td>
				        			<td align="right">
				        				<div class="form-group">
											<label for="qq">QQ：</label>
										</div>
				        			</td>
				        			<td>
				        				<div class="form-group">
											<input type="text" class="form-control" name="qq" id="qq" placeholder="">
										</div>
				        			</td>
				        		</tr>
				        		<tr>
				        			<td align="right">
				        				<div class="form-group">
											<label for="email">邮箱：</label>
										</div>
				        			</td>
				        			<td>
				        				<div class="form-group">
											<input type="text" class="form-control" name="email" id="email" placeholder="">
										</div>
				        			</td>
				        			<td align="right">
				        				<div class="form-group">
											<label for="address">通信地址：</label>
										</div>
				        			</td>
				        			<td>
				        				<div class="form-group">
				        					<input type="text" class="form-control" name="address" id="address" placeholder="">
										</div>
				        			</td>
				        		</tr>
				        		<tr>
				        			<td align="right">
				        				<div class="form-group">
											<label for="remark">备注：</label>
										</div>
				        			</td>
				        			<td colspan="3">
				        				<textarea rows="" cols="" class="form-control" name="remark" id="remark"></textarea>
				        			</td>
				        		</tr>				        		
				        	</table>
				        	<table>
				        		<tr>
				        			<td>
						        		<button type="button" class="btn btn-default" data-dismiss="modal" name="zjjclose" id="zjjclose">关闭</button>
										<button type="button" class="btn btn-primary" name="zjjpreserve1" id="zjjpreserve1">保存</button>
				        			</td>
				        		</tr>
				        	</table>
				        </form>
				      </div>
				    </div>
				  </div>
				</div>
			
			<!-- 显示数据 -->
			<table class="table table-bordered table-condensed table-hover">
				<tr align="center">
					<td></td>
					<td>头像</td>
					<td>会员号</td>
					<td>手机</td>
					<td>姓名</td>
					<td>昵称</td>
					<td>性别</td>
					<td>店铺名称</td>
					<td>微信状态</td>
					<td>QQ</td>
					<td>邮箱</td>
					<td>出生日期</td>
					<td>最近到店时间</td>
					<td>注册方式</td>
					<td>修改</td>
					<td>查看详情</td>
					<td>删除</td>
				</tr>
				<c:forEach items="${info.list }" var="list" varStatus="s">
					<tr align="center" >
						<td>${s.index+1 }</td>
						<%-- <td>${list.photo }</td> --%>
						<td><img src="/bsc${list.photo }" width="90px" height="75px"/></td>
						<td>${list.custom_user_id }</td>
						<td>${list.mobile }</td>
						<td>${list.username }</td>
						<td>${list.nikename }</td>
						<%-- <td>${list.sex }</td> --%>
						<td>
							<c:if test="${list.sex==1 }">
								男
							</c:if>
							<c:if test="${list.sex==2 }">
								女
							</c:if>
							<c:if test="${list.sex==3 }">
								保密
							</c:if>
						</td>
						<td>${list.shop_name }</td>
						<%-- <td>${list.wechat_status }</td> --%>
						<td>
							<c:if test="${list.wechat_status==1 }">
								未订阅
							</c:if>
							<c:if test="${list.wechat_status==2 }">
								已订阅
							</c:if>
							<c:if test="${list.wechat_status==3 }">
								已退订
							</c:if>
						</td>
						<td>${list.qq }</td>
						<td>${list.email }</td>
						<td><f:formatDate value="${list.born_date }" pattern="yyyy-MM-dd" /></td>
						<%-- <td>${list.born_date }</td>
						<td>${list.recent_time }</td> --%>
						<td><f:formatDate value="${list.recent_time }" pattern="yyyy-MM-dd" /></td>
						<%-- <td>${list.enroll_mode }</td> --%>
						<td>
							<c:if test="${list.enroll_mode==1 }">
								微信
							</c:if>
							<c:if test="${list.enroll_mode==2 }">
								商家
							</c:if>
							<c:if test="${list.enroll_mode==3 }">
								后台
							</c:if>
						</td>
						<td>
							<button type="button" class="btn btn-primary btn-xs" onclick="test2('${list.custom_user_id }')" data-toggle="modal" data-target="#myModal2" data-backdrop="static">
								<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>&nbsp;&nbsp;修改
							</button>
						</td>
						<td>
							<a href="${pageContext.request.contextPath }/zjj/findByIdBis_custom_user1/${list.custom_user_id}">
								<button class="btn btn-primary btn-xs" type="button" >
									<span class="glyphicon glyphicon-search" aria-hidden="true"></span>&nbsp;&nbsp;查看详情
								</button>
							</a>
						</td>
						<td>
							<button class="btn btn-primary btn-xs" type="button" onclick="test3('${list.custom_user_id}')" data-toggle="modal" data-target="#myModal3" data-backdrop="static">
								<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>&nbsp;&nbsp;删除
							</button>
						</td>
					</tr>
				</c:forEach>
			</table>
			
			<!-- 删除模态框 -->
			<div class="modal fade bs-example-modal-lg" id="myModal3" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
			  <div class="modal-dialog modal-lg" role="document">
			    <div class="modal-content">
			      <div class="modal-header">
			        <button type="button" class="close" data-dismiss="modal" onclick="test222()" aria-label="Close"><span aria-hidden="true">&times;</span></button>
			        <h4 class="modal-title" align="left">确认</h4>
			      </div>
			      <div class="modal-body">			      	
			      	<form class="form-horizontal" name="myform3" id="myform3">
			      		<!-- 隐藏域 编号 -->
			      		<input type="hidden" name="custom_user_id" id="custom_user_id2">
			      		<div class="form-group"">
						  	<h3><span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span>&nbsp;&nbsp;你确定要删除该条数据吗？</h3>
						</div>
						<div class="form-group"">
							<button type="button" class="btn btn-default" name="zjjdelete3" id="zjjdelete3">确定</button>
					        <button type="button" class="btn btn-default" data-dismiss="modal" name="zjjclose3" id="zjjclose3">取消</button>
					    </div>
					</form>
			      </div>
			    </div>
			  </div>
			</div>
			
			<!-- 修改模态框 -->
			<div class="modal fade bs-example-modal-lg" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
				  <div class="modal-dialog modal-lg" role="document">
				    <div class="modal-content">
				      <div class="modal-header">
				        <button type="button" class="close" data-dismiss="modal" onclick="test22()" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				        <h4 class="modal-title" align="left">修改顾客信息</h4>
				      </div>
				      <div class="modal-body">
				      	<%-- <form name="myform2" id="myform2"> --%>
				      	<form action="" name="myform2" id="myform2" method="post" enctype="multipart/form-data">
				      	<input type="hidden" name="photo" id="photo">
				        	<table class="table table-bordered">
				        		<!-- 隐藏域 编号 -->
				        		<input type="hidden" class="form-control" name="custom_user_id" id="custom_user_id1" placeholder="">      		
				        		<tr>
				        			<td align="right">
				        				<div class="form-group">
											<label for="mobile">手机:</label>
										</div>
				        			</td>
				        			<td>
				        				 <div class="form-group">
										    <input type="text" class="form-control" name="mobile" id="mobile1" placeholder="">
										 </div>
				        			</td>
				        			<td align="right">
				        				<div class="form-group">
											<label for="photo">头像：</label>
										</div>
				        			</td>
				        			<td>
				        				<div class="form-group">
										    <img src=""  id="photo1" width="120px" height="100px"/>
										    <input type="file" class="form-control" onchange="PreviewImage1(this)" name=file id="file" placeholder="">
										  	<div id="imgPreview1"></div>
										</div>
				        			</td>
				        		</tr>
				        		<tr>
				        			<td align="right">
				        				<div class="form-group">
											<label for="username">姓名：</label>
										</div>
				        			</td>
				        			<td>
				        				<div class="form-group">
										    <input type="text" class="form-control" name="username" id="username1" placeholder="">
										</div>
				        			</td>
				        			<td align="right">
				        				<div class="form-group">
											<label for="sex">性别：</label>
										</div>
				        			</td>
				        			<td>
				        				<div class="form-group">
										    <select class="form-control" name="sex" id="sex1">
												<option value="1">男</option>
												<option value="2">女</option>											
												<option value="3">保密</option>
											</select>
										</div>
				        			</td>
				        		</tr>
				        		<tr>
				        			<td align="right">
				        				<div class="form-group">
											<label for="nikename">昵称：</label>
										</div>
				        			</td>
				        			<td>
				        				<div class="form-group">
										    <input type="text" class="form-control" name="nikename" id="nikename1" placeholder="">
										</div>
				        			</td>
				        			<td align="right">
				        				<div class="form-group">
											<label for="born_date">出生日期：</label>
										</div>
				        			</td>
				        			<td>
				        				<div class="form-group">
										    <input type="date" class="form-control" name="born_date" id="born_date1" placeholder="">
										</div>
				        			</td>
				        		</tr>
				        		<tr>
				        			<td align="right">
				        				<div class="form-group">
											<label for="phone">电话：</label>
										</div>
				        			</td>
				        			<td>
				        				<div class="form-group">
				        					<input type="text" class="form-control" name="phone" id="phone1" placeholder="">
										</div>
				        			</td>
				        			<td align="right">
				        				<div class="form-group">
											<label for="qq">QQ：</label>
										</div>
				        			</td>
				        			<td>
				        				<div class="form-group">
											<input type="text" class="form-control" name="qq" id="qq1" placeholder="">
										</div>
				        			</td>
				        		</tr>
				        		<tr>
				        			<td align="right">
				        				<div class="form-group">
											<label for="email">邮箱：</label>
										</div>
				        			</td>
				        			<td>
				        				<div class="form-group">
											<input type="text" class="form-control" name="email" id="email1" placeholder="">
										</div>
				        			</td>
				        			<td align="right">
				        				<div class="form-group">
											<label for="address">通信地址：</label>
										</div>
				        			</td>
				        			<td>
				        				<div class="form-group">
				        					<input type="text" class="form-control" name="address" id="address1" placeholder="">
										</div>
				        			</td>
				        		</tr>
				        		<tr>
				        			<td align="right">
				        				<div class="form-group">
											<label for="remark">备注：</label>
										</div>
				        			</td>
				        			<td colspan="3">
				        				<textarea rows="" cols="" class="form-control" name="remark" id="remark1"></textarea>
				        			</td>
				        		</tr>				        		
				        	</table>
				        	<table>
				        		<tr>
				        			<td>
						        		<button type="button" class="btn btn-default" data-dismiss="modal" name="zjjclose2" id="zjjclose2">关闭</button>
										<button type="button" class="btn btn-primary" name="zjjpreserve2" id="zjjpreserve2">保存</button>
				        			</td>
				        		</tr>
				        	</table>
				        </form>
				      </div>
				    </div>
				  </div>
				</div>
				
				<!-- 分页 -->
				<a href="#" onclick="first()">首页</a>
				&nbsp;&nbsp;&nbsp;
				<a href="#" onclick="pre()">上一页</a>
				&nbsp;&nbsp;&nbsp;
				<a href="#" onclick="next()">下一页</a>
				&nbsp;&nbsp;&nbsp;
				<a href="#" onclick="last()">尾页</a>
			
		</center>
	<!-- </div> -->
</body>
</html>
<script type="text/javascript">
	//条件查询定值方法
	$(function(){
		$("#shop_id").val('${shop_id}');
		$("#enroll_mode").val('${enroll_mode}');
		$("#wechat_status").val('${wechat_status}');
	})
	
	//分页
	//首页
	function first(){
		document.forms[0].action="${pageContext.request.contextPath }/zjj/selectBis_custom_user?page=${info.firstPage}";
		document.forms[0].submit();lase
	}
	//上一页
	function pre(){
		document.forms[0].action="${pageContext.request.contextPath }/zjj/selectBis_custom_user?page=${info.prePage}";
		document.forms[0].submit();
	}
	//下一页
	function next(){
		document.forms[0].action="${pageContext.request.contextPath }/zjj/selectBis_custom_user?page=${info.nextPage}";
		document.forms[0].submit();
	}
	//尾页
	function last(){
		document.forms[0].action="${pageContext.request.contextPath }/zjj/selectBis_custom_user?page=${info.lastPage}";
		document.forms[0].submit();
	}
	
	function PreviewImage(imgFile) {
		path = window.URL.createObjectURL(imgFile.files[0]);
        document.getElementById("imgPreview").innerHTML = "<img id='img1' width='120px' height='100px' src='" + path + "'/>";
	}
	
	function PreviewImage1(imgFile) {
		path = window.URL.createObjectURL(imgFile.files[0]);
        document.getElementById("imgPreview1").innerHTML = "<img id='img1' width='120px' height='100px' src='" + path + "'/>";
	}
	
	//点击重置按钮 重置
	$("#zjjresetting").click(
		function() {
			$("#mobile").val("");
			$("#username").val("");
			$("#shop_id").val("");
			$("#enroll_mode").val("");
			$("#custom_user_id").val("");
			$("#nikename").val("");
			$("#wechat_status").val("");
			$("#recent_time").val("");
		}
	)
	
	//点击模态框 关闭按钮 刷新当前界面
	//添加
	$("#zjjclose").click(
		function() {
			console.log("---");
			window.location.href = "${pageContext.request.contextPath }/zjj/selectBis_custom_user";
	});
	//修改
	$("#zjjclose2").click(
		function() {
			console.log("---");
			window.location.href = "${pageContext.request.contextPath }/zjj/selectBis_custom_user";
	});
	//删除
	$("#zjjclose3").click(
		function() {
			console.log("---");
			window.location.href = "${pageContext.request.contextPath }/zjj/selectBis_custom_user";
	});
	
	//点击模态框关闭图标 关闭模态框 刷新当前页面
	//添加
	function test1 () {
        console.log('----');
        window.location.href = "${pageContext.request.contextPath }/zjj/selectBis_custom_user";
    }
	//修改
	function test22 () {
        console.log('----');
        window.location.href = "${pageContext.request.contextPath }/zjj/selectBis_custom_user";
    }
	//删除
	function test222 () {
        console.log('----');
        window.location.href = "${pageContext.request.contextPath }/zjj/selectBis_custom_user";
    }
	
	//开始添加表单验证
	var form1 = $('#myform1');
	$(document).ready(function() {
		form1.bootstrapValidator({
			message: '输入值不合法',
			feedbackIcons: {
				valid: 'glyphicon glyphicon-ok',
				invalid: 'glyphicon glyphicon-remove',
				validating: 'glyphicon glyphicon-refresh'
			},
			fields: {
				mobile: {
					validators: {
						notEmpty: {
							message: '手机号不能为空'
						},
						regexp: {
							//regexp: "^([0-9]{11})?$",
							//regexp: /^1[3|5|8|9]{1}[0-9]{9}$/,
							//regexp:/^1[345789]\d{9}$/,
							regexp: "^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\\d{8}$",
							message: '手机号码格式错误'
						},
						remote: {
				            message: '手机号重复',
				            url: '${pageContext.request.contextPath }/zjj/findByIdBis_custom_usermobile',
				            data : function(){
				            	return{
				            		mobile:$("#mobile").val()
				            	}	
				            },//这里默认会传递该验证字段的值到后端
				            delay:2000 //这里特别要说明，必须要加此属性，否则用户输入一个字就会访问后台一次，会消耗大量的系统资源，
						}
					}
				},
				username: {
					message: '姓名不合法',
					validators: {
						notEmpty: {
							message: '姓名不能为空'
						},
						stringLength: {
							min: 2,
							max: 30,
							message: '请输入2到30个字符'
						},
						regexp: {
							regexp: /^[a-zA-Z0-9_\. \u4e00-\u9fa5 ]+$/,
							message: '姓名只能由字母、数字、点、下划线和汉字组成 '
						}
					}
				},
				nikename: {
					message: '昵称不合法',
					validators: {
						stringLength: {
							min: 2,
							max: 30,
							message: '请输入2到30个字符'
						},
						regexp: {
							regexp: /^[a-zA-Z0-9_\. \u4e00-\u9fa5 ]+$/,
							message: '昵称只能由字母、数字、点、下划线和汉字组成 '
						}
					}
				},
				phone: {
					message: '电话不合法',
					validators: {
						regexp: {
							regexp: /[0-9-()]{7,18}/,
							message: '电话格式错误'
						},
						remote: {
				            message: '电话重复',
				            url: '${pageContext.request.contextPath }/zjj/findByIdBis_custom_userphone',
				            data : function(){
				            	return{
				            		phone:$("#phone").val()
				            	}	
				            },//这里默认会传递该验证字段的值到后端
				            delay:2000 //这里特别要说明，必须要加此属性，否则用户输入一个字就会访问后台一次，会消耗大量的系统资源，
						}
					}
				},
				qq: {
					message: 'QQ不合法',
					validators: {
						regexp: {
							regexp: /^[1-9][0-9]{4,10}$/,
							message: 'QQ格式错误'
						},
						remote: {
				            message: 'QQ重复',
				            url: '${pageContext.request.contextPath }/zjj/findByIdBis_custom_userqq',
				            data : function(){
				            	return{
				            		qq:$("#qq").val()
				            	}	
				            },//这里默认会传递该验证字段的值到后端
				            delay:2000 //这里特别要说明，必须要加此属性，否则用户输入一个字就会访问后台一次，会消耗大量的系统资源，
						}
					}
				},
				email: {
					message: '邮箱不合法',
					validators: {
						emailAddress: {
							message: '请输入正确的邮件地址如：123@qq.com'
						},
						remote: {
				            message: '邮箱重复',
				            url: '${pageContext.request.contextPath }/zjj/findByIdBis_custom_useremail',
				            data : function(){
				            	return{
				            		email:$("#email").val()
				            	}	
				            },//这里默认会传递该验证字段的值到后端
				            delay:2000 //这里特别要说明，必须要加此属性，否则用户输入一个字就会访问后台一次，会消耗大量的系统资源，
						}
					}
				},
				address: {
					message: '通信地址不合法',
					validators: {
						stringLength: { //检测长度 
							min: 4,
							max: 60,
							message: '请输入4到60个字符'
						},
						regexp: {
							regexp: /^[\u4E00-\u9FA5A-Za-z0-9_]+$/,
							message: '通信地址格式错误'
						}
					}
				},
			}
		});
		
		//添加模态框点击保存 保存数据
		//点击保存按钮进行 表单验证 
		//验证成功 提交表单 刷新界面
		$("#zjjpreserve1").click(
			function() {
				console.log("---");
				//进行表单验证
				var bv1 = form1.data('bootstrapValidator');
				bv1.validate();
				if(bv1.isValid()) {
					console.log("+++");
					if(window.confirm("是否保存添加~！")) {
						/* $.ajax({
							type:"POST",
					        url:"${pageContext.request.contextPath }/zjj/insertBis_custom_user",
					        data : $("#myform1").serialize(),
				            success: function (result) {
					            //由于ajax发送的url到控制层不会进行页面的跳转，因为当请求成功以后，请求依然会回success,所以可以在此再写一遍url进行跳转
					            window.location.href="${pageContext.request.contextPath }/zjj/selectBis_custom_user";
				            }
					    }); */
						document.forms[1].action="${pageContext.request.contextPath }/zjj/insertBis_custom_user";
				        document.forms[1].submit();
					}
				}
			}		
		);
		
	});
	//添加表单验证结束
	
	//点击修改按钮 将当前行数据ID传递到模态框
	function test2 (custom_user_id) {
		$.ajax({
    		url:'${pageContext.request.contextPath }/zjj/findByIdBis_custom_user',
    		type:'post',
    		data:{"custom_user_id":custom_user_id},
    		success:function(msg){
			 	var ms=eval('('+msg+')');
			 	$("#custom_user_id1").val(ms.custom_user_id);
			 	$("#mobile1").val(ms.mobile);
			 	//$("#photo1").val(ms.photo);
			 	var img = ("/bsc"+ms.photo);
			 	document.getElementById("photo1").src=img;
			 	$("#photo").val(ms.photo);
        		$("#username1").val(ms.username);
        		$("#sex1").val(ms.sex);
        		$("#nikename1").val(ms.nikename);
        		//$("#born_date1").val(ms.born_date);
        		//以下是后台返回毫秒 给日期控件赋值
        		//开始
			    var now=new Date(ms.born_date);
			    //alert(now.getDate()+'-'+now.getMonth());
			  	//格式化日，如果小于9，前面补0
			  	var day = ("0" + now.getDate()).slice(-2);
			  	//格式化月，如果小于9，前面补0
			 	 var month = ("0" + (now.getMonth() + 1)).slice(-2);
			  	//拼装完整日期格式
			  	var today = now.getFullYear()+"-"+(month)+"-"+(day) ;
			    //alert(today);
			    $('#born_date1').val(today);
			    //完成赋值
        		$("#phone1").val(ms.phone);
			    //结束
        		$("#qq1").val(ms.qq);
        		$("#email1").val(ms.email);
        		$("#address1").val(ms.address);
        		$("#remark1").val(ms.remark);
    		}
    	});
    }
	
	//开始修改表单验证
	var form2 = $('#myform2');
	$(document).ready(function() {
		form2.bootstrapValidator({
			message: '输入值不合法',
			feedbackIcons: {
				valid: 'glyphicon glyphicon-ok',
				invalid: 'glyphicon glyphicon-remove',
				validating: 'glyphicon glyphicon-refresh'
			},
			fields: {
				mobile: {
					validators: {
						notEmpty: {
							message: '手机号不能为空'
						},
						regexp: {
							//regexp: "^([0-9]{11})?$",
							//regexp: /^1[3|5|8|9]{1}[0-9]{9}$/,
							//regexp:/^1[345789]\d{9}$/,
							regexp: "^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\\d{8}$",
							message: '手机号码格式错误'
						}
					}
				},
				username: {
					message: '姓名不合法',
					validators: {
						notEmpty: {
							message: '姓名不能为空'
						},
						stringLength: {
							min: 2,
							max: 30,
							message: '请输入2到30个字符'
						},
						regexp: {
							regexp: /^[a-zA-Z0-9_\. \u4e00-\u9fa5 ]+$/,
							message: '姓名只能由字母、数字、点、下划线和汉字组成 '
						}
					}
				},
				nikename: {
					message: '昵称不合法',
					validators: {
						stringLength: {
							min: 2,
							max: 30,
							message: '请输入2到30个字符'
						},
						regexp: {
							regexp: /^[a-zA-Z0-9_\. \u4e00-\u9fa5 ]+$/,
							message: '昵称只能由字母、数字、点、下划线和汉字组成 '
						}
					}
				},
				phone: {
					message: '电话不合法',
					validators: {
						regexp: {
							regexp: /[0-9-()]{7,18}/,
							message: '电话格式错误'
						}
					}
				},
				qq: {
					message: 'QQ不合法',
					validators: {
						regexp: {
							regexp: /^[1-9][0-9]{4,10}$/,
							message: 'QQ格式错误'
						}
					}
				},
				email: {
					message: '邮箱不合法',
					validators: {
						emailAddress: {
							message: '请输入正确的邮件地址如：123@qq.com'
						}
					}
				},
				address: {
					message: '通信地址不合法',
					validators: {
						stringLength: { //检测长度 
							min: 4,
							max: 60,
							message: '请输入4到60个字符'
						},
						regexp: {
							regexp: /^[\u4E00-\u9FA5A-Za-z0-9_]+$/,
							message: '通信地址格式错误'
						}
					}
				},
			}
		});
		
		//修改模态框点击保存 保存数据
		//点击保存按钮进行 表单验证 
		//验证成功 提交表单 刷新界面
		$("#zjjpreserve2").click(
			function() {
				console.log("---");
				//进行表单验证
				var bv2 = form2.data('bootstrapValidator');
				bv2.validate();
				if(bv2.isValid()) {
					console.log("+++");
					if(window.confirm("是否保存修改~！")) {
						/* $.ajax({
							type:"POST",
					        url:"${pageContext.request.contextPath }/zjj/updateBis_custom_user",
					        data : $("#myform2").serialize(),
				            success: function (result) {
					            //由于ajax发送的url到控制层不会进行页面的跳转，因为当请求成功以后，请求依然会回success,所以可以在此再写一遍url进行跳转
					            window.location.href="${pageContext.request.contextPath }/zjj/selectBis_custom_user";
				            }
					    }); */
						document.forms[3].action="${pageContext.request.contextPath }/zjj/updateBis_custom_user";
				        document.forms[3].submit();
					}
				}
			}		
		);
		
	});
	//修改表单验证结束
	
	//点击删除按钮 将当前行数据ID传值到模态框 并打开模态框
	function test3 (custom_user_id) {
		console.log("----");
		$("#custom_user_id2").val(custom_user_id);
    }
	
	//删除
	//点击确定按钮 提交表单 删除
	$("#zjjdelete3").click(
		function() {
			console.log("删除");
			$.ajax({
				type : "POST",
				url : "${pageContext.request.contextPath }/zjj/deleteBis_custom_user",
				data:{"custom_user_id":$("#custom_user_id2").val()},
				success : function(result) {
					//由于ajax发送的url到控制层不会进行页面的跳转，因为当请求成功以后，请求依然会回success,所以可以在此再写一遍url进行跳转
					window.location.href = "${pageContext.request.contextPath }/zjj/selectBis_custom_user";
				}
			});
	});
</script>